﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LCA.Community.DAL.Interfaces;
using LCA.Community.DAL.Model;

namespace LCA.Community.DAL.Test.Mocks
{
    public class FakeStorageServiceContext<T> : IStorageServiceContext<T> where T : BasicStorageModel
    {
        private static List<T> _entities;
        private Uri _baseURL;

        public FakeStorageServiceContext()
        {
            if(_entities == null) _entities = new List<T>();

            _baseURL = new Uri(String.Format("{0}","http://www.storageservice.com"));
        }

        public void Add(T entity)
        {
            _entities.Add(entity);
        }

        public void Delete(T entity)
        {
            _entities.Remove(entity);
        }

        public Uri GetUrl(T entity)
        {
            return _entities.Where(e => e.Name == entity.Name).FirstOrDefault().Url;
        }

        public bool Exist(T entity)
        {
            return _entities.Contains(entity);
        }

        public Uri BaseURL
        {
            get
            {
                return _baseURL;
            }
        }
    }
}
